package com.ruoyi.web.controller.prevention;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.PreventionHiddenInventoryFile;
import com.ruoyi.system.service.PreventionHiddenInventoryFileService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 隐患清单_附件表(PreventionHiddenInventoryFile)表控制层
 * @since 2023-04-13 09:39:48
 */
@RestController
@RequestMapping("preventionHiddenInventoryFile")
public class PreventionHiddenInventoryFileController  extends BaseController {

    @Resource
    private PreventionHiddenInventoryFileService preventionHiddenInventoryFileService;

    /**
     * 分页查询
     * @return 查询结果
     */
    @GetMapping
    public TableDataInfo queryByPage(PreventionHiddenInventoryFile preventionHiddenInventoryFile) {
        startPage();
        List<PreventionHiddenInventoryFile> preventionHiddenInventoryFiles = this.preventionHiddenInventoryFileService.queryByPage(preventionHiddenInventoryFile);
        return getDataTable(preventionHiddenInventoryFiles);
    }

    /**
     * 通过主键查询单条数据
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<PreventionHiddenInventoryFile> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.preventionHiddenInventoryFileService.queryById(id));
    }

    /**
     * 新增数据
     * @param preventionHiddenInventoryFile 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<PreventionHiddenInventoryFile> add(PreventionHiddenInventoryFile preventionHiddenInventoryFile) {
        return ResponseEntity.ok(this.preventionHiddenInventoryFileService.insert(preventionHiddenInventoryFile));
    }

    /**
     * 编辑数据
     * @param preventionHiddenInventoryFile 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<PreventionHiddenInventoryFile> edit(PreventionHiddenInventoryFile preventionHiddenInventoryFile) {
        return ResponseEntity.ok(this.preventionHiddenInventoryFileService.update(preventionHiddenInventoryFile));
    }

    /**
     * 删除数据
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.preventionHiddenInventoryFileService.deleteById(id));
    }

}

